

<template>
  <el-config-provider  :local="i18nLocale">
    <router-view/>
    <LockScreen v-if="getThemeConfig.isLockScreen" />
    <Setings ref="setingsRef" v-show="getThemeConfig.loclScreenTime !==0" />
    <CloseFull />
  </el-config-provider>
</template>
<script  lang="ts">
import { set } from 'nprogress';
import {computed,ref,getCurrentInstance, onBeforeMount, onMounted, onUnmounted, nextTick, defineComponent, watch, reactive, toRefs} from 'vue';
import {useRoute} from 'vue-router';
import { useStore } from './store/index';
import {Local,Session} from './utils/storage';
import other from '/@/utils/other';
import setIntroduction  from '/@/utils/setIconfont'
import LockScreen from '/@/layout/lockScreen/index.vue';
import Setings from '/@/layout/navBars/breadcrumb/setings.vue';
import CloseFull from '/@/layout/navBars/breadcrumb/closeFull.vue'
export default defineComponent({
  name:'app',
  components:{LockScreen,Setings,CloseFull},
  setup(){
    const {proxy} = <any>getCurrentInstance();
    const setingsRef = ref();
		const route = useRoute();
		const store = useStore();
		const state = reactive({
			i18nLocale: null,
		});
    // 
    const getThemeConfig = computed(() => {
			return store.state.themeConfig.themeConfig;
		});
    // 获取全局组件大小
    const getGlobalComponentSize = computed(()=>{
      return other.globalComponentSize;
    })
    // 布局配置弹窗打开
    const openSetingsDrawer = ()=>{
      setingsRef.value.openDrawer();
    }
    onBeforeMount(()=>{
      setIntroduction.cssCdn();
      setIntroduction.jsCdn();
    }),
    onMounted(()=>{
      nextTick(()=>{
        proxy.mittBus.on('openSetingsDrawer',()=>{
          openSetingsDrawer()
        })
        proxy.mittBus.on('getI18nConfig',(locale:string)=>{
          (state.i18nLocale as string |null) = locale;
        })
        if(Local.get('themeConfig')){
          store.dispatch('themeConfig/setThemeConfig',Local.get('themeConfig'));
          document.documentElement.style.cssText = Local.get('themeConfigStyle');

        }
        if(Session.get('isTagsViewCurrentFull')){
          store.dispatch('tagsViewRoutes/SetCurrentFullscreen',Session.get('isTagsViewCurrentFull'));
        }

      })
    }),
    onUnmounted(()=>{
      proxy.mittBus('openSetingsDrawer',()=>{})
      proxy.mittBus('getI18nConfig',()=>{})
    }),
    watch(
      () => route.path,
			() => {
				// other.useTitle();
			}
    );
    return {
      setingsRef,
      getGlobalComponentSize,
      getThemeConfig,
      ...toRefs(state)
    }
  }
})


</script>
